home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4349 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: mudskipper.cac.psu.edu!user
  2. From: fcusack@tdx.org (frank.)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: simple code, argc, ar
  5. Date: Sat, 03 Feb 1996 16:55:27 -0400
  6. Organization: Penn State University, Center for Academic Computing
  7. Message-ID: <fcusack-0302961655270001@mudskipper.cac.psu.edu>
  8. References: <4eurnq$8oc@gail.ripco.com>
  9. NNTP-Posting-Host: mudskipper.cac.psu.edu
  10.  
  11. In article <4eurnq$8oc@gail.ripco.com>, mambuhl@ripco.com (Martin Ambuhl) wrote:
  12.  
  13. > otisg@panther.middlebury.edu (Otis Gospodnetic)
  14. > in <11f7cc$17261a.3b3@daprez> asks:
  15. > [snip]
  16. > >Problem - I am doing something wrong and I almost always end up calling
  17. > >Usage() even if I use the program correctly.
  18. > [snip]
  19. > >  if (!strcmp(argv[1],"-d") || !strcmp(argv[1],"-e")) {
  20. > >    Usage();
  21. > Suppose arv[1] is "-d", then this is
  22. >     if (1 /* || !strcmp(argv[1],"-e") */) ...
  23. > Suppose argv[2] is "-e", then it is
  24. >     if (0 || 1) ...
  25. > Only when argv[1] is neither "-d" nor "-e" is Usage() called.
  26.  
  27. Actually, your example proves the opposite - when argv[1] is "-e" or "-d"
  28. Usage() is called.
  29.  
  30. > Try
  31. > >  if (strcmp(argv[1],"-d") && strcmp(argv[1],"-e")) {
  32.  
  33. good! A lot better than my double negative comparison in a differnet followup
  34. ~Frank
  35.  -- I am Pentium of Borg.  Division is futile.  You will be approximated. --
  36.  --   If you build it, they will come --> http://www.tdx.org/~fcusack/    --
  37.  -- PGP key fingerprint: 01 C0 C0 B9 CC 78 67 0F  3F 64 80 65 8B 0F F9 EA --
  38.